REDHQ = COMMANDCENTER:New( GROUP:FindByName( "RED HQ" ), "铁血工造指挥部")
BLUEHQ = COMMANDCENTER:New( GROUP:FindByName( "HQ" ), "格里芬指挥部")

MESSAGE:New("任务规划中", 10, "纵向应变子任务", true):ToAll()

BLUE_SCORE = SCORING:New("纵向应变子任务分数")

BLUE_Mission = MISSION:New( BLUEHQ, "纵向应变", "可选",
	"欢迎来到纵向应变任务\n" ..
	"你作为格里芬委托IOP建造的空军人形，需要进行长途奔袭并协助争夺第比利斯机场以及该区域的所有机场\n" .. 
	"协助我方的运输机到达空域完成空中输送任务。\n" .. 
	"注意该战区拥有大量高炮作为对空防御。\n" .. 
	"祝好运!",
	coalition.side.BLUE
	)

RED_Mission = MISSION:New( REDHQ, "纵向应变", "可选",
	"欢迎来到纵向应变任务\n" ..
	"你作为铁血工造的精英空军人形，需要从机场出发长途奔袭至任务区域后执行战略空投任务。\n" .. 
	"注意战区没有任何空中支援。\n" .. 
	"祝好运!",
	coalition.side.RED
	)

BLUE_Mission:AddScoring( BLUE_SCORE )

BLUE_Mission:Start()
RED_Mission:Start()

-- SETS
BLUE_PLANES_SET = SET_GROUP:New():FilterCoalitions("blue"):FilterStart()
RED_PLANES_SET = SET_GROUP:New():FilterCoalitions("red"):FilterStart()

-- capturezone init
Capture_ZONE_01 = ZONE:New( "铁血基地前哨机场区域" )
Capture_ZONE_02 = ZONE:New( "铁血瓦兹亚尼基地" )

ZoneCapture_01 = ZONE_CAPTURE_COALITION:New( Capture_ZONE_01, coalition.side.BLUE )
ZoneCapture_02 = ZONE_CAPTURE_COALITION:New( Capture_ZONE_02, coalition.side.BLUE )

-- Zone1 start
function ZoneCapture_01:OnEnterGuarded( From, Event, To )
	if From ~= To then
		local Coalition = self:GetCoalition()
		self:E( { Coalition = Coalition } )
		if Coalition == coalition.side.BLUE then
			ZoneCapture_01:Smoke( SMOKECOLOR.Blue )
			BLUEHQ:MessageTypeToCoalition( string.format( "%s 在格里芬的控制下", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )
			REDHQ:MessageTypeToCoalition( string.format( "%s 在格里芬的控制下", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )
		else
			ZoneCapture_01:Smoke( SMOKECOLOR.Red )
			BLUEHQ:MessageTypeToCoalition( string.format( "%s 在铁血工造的控制下", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )
			REDHQ:MessageTypeToCoalition( string.format( "%s 在铁血工造的控制下", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )
		end
	end
end

function ZoneCapture_01:OnEnterEmpty()
	self:Smoke( SMOKECOLOR.Green )
	BLUEHQ:MessageTypeToCoalition( string.format( "%s 成为中立地带，请协助占领该区域", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )
	REDHQ:MessageTypeToCoalition( string.format( "%s 成为中立地带，请协助占领该区域", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )
end

function ZoneCapture_01:OnEnterAttacked()
	ZoneCapture_01:Smoke( SMOKECOLOR.White )

	local Coalition = self:GetCoalition()

	self:E( {Coalition = Coalition })

	if Coalition == coalition.side.BLUE then
		BLUEHQ:MessageTypeToCoalition( string.format( "%s 正在被铁血工造袭击！", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )
		REDHQ:MessageTypeToCoalition( string.format( "我们正在进攻 %s", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )	
	else
		BLUEHQ:MessageTypeToCoalition( string.format( "我们正在进攻 %s", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )
		REDHQ:MessageTypeToCoalition( string.format( "%s 正在被格里芬袭击！", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )	
	end
end

function ZoneCapture_01:OnEnterCaptured()
	local Coalition = self:GetCoalition()
	self:E( { Coalition = Coalition })

	if Coalition == coalition.side.BLUE then
		BLUEHQ:MessageTypeToCoalition( string.format( "格里芬成功占领了 %s。 现在由404小队接手防御", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )
		REDHQ:MessageTypeToCoalition( string.format( "%s已经被格里芬攻占", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )	
	else
		BLUEHQ:MessageTypeToCoalition( string.format( "%s 已经被铁血工造占领", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )
		REDHQ:MessageTypeToCoalition( string.format( "铁血工造成功占领了 %s。 现在由'稻草人'接手防御", ZoneCapture_01:GetZoneName()), MESSAGE.Type.Information )	
	end

	self:__Guard( 30 )

end
-- Zone1 end

-- Zone2 start
function ZoneCapture_02:OnEnterGuarded( From, Event, To )
	if From ~= To then
		local Coalition = self:GetCoalition()
		self:E( { Coalition = Coalition } )
		if Coalition == coalition.side.BLUE then
			ZoneCapture_02:Smoke( SMOKECOLOR.Blue)
			BLUEHQ:MessageTypeToCoalition( string.format( "%s 在格里芬的控制下", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )
			REDHQ:MessageTypeToCoalition( string.format( "%s 在格里芬的控制下", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )
		else
			ZoneCapture_02:Smoke( SMOKECOLOR.Red)
			BLUEHQ:MessageTypeToCoalition( string.format( "%s 在铁血工造的控制下", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )
			REDHQ:MessageTypeToCoalition( string.format( "%s 在铁血工造的控制下", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )
		end
	end
end

function ZoneCapture_02:OnEnterEmpty()
	self:Smoke( SMOKECOLOR.Green )
	BLUEHQ:MessageTypeToCoalition( string.format( "%s 成为中立地带，请协助占领该区域", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )
	REDHQ:MessageTypeToCoalition( string.format( "%s 成为中立地带，请协助占领该区域", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )
end

function ZoneCapture_02:OnEnterAttacked()
	ZoneCapture_02:Smoke( SMOKECOLOR.White )

	local Coalition = self:GetCoalition()

	self:E( {Coalition = Coalition })

	if Coalition == coalition.side.BLUE then
		BLUEHQ:MessageTypeToCoalition( string.format( "%s 正在被铁血工造袭击！", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )
		REDHQ:MessageTypeToCoalition( string.format( "我们正在进攻 %s", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )	
	else
		BLUEHQ:MessageTypeToCoalition( string.format( "我们正在进攻 %s", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )
		REDHQ:MessageTypeToCoalition( string.format( "%s 正在被格里芬袭击！", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )	
	end
end

function ZoneCapture_02:OnEnterCaptured()
	local Coalition = self:GetCoalition()
	self:E( { Coalition = Coalition })

	if Coalition == coalition.side.BLUE then
		BLUEHQ:MessageTypeToCoalition( string.format( "格里芬成功占领了 %s。 现在由404小队接手防御，请协助巩固防御！", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )
		REDHQ:MessageTypeToCoalition( string.format( "%s已经被格里芬攻占", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )	
	else
		BLUEHQ:MessageTypeToCoalition( string.format( "%s 已经被铁血工造占领", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )
		REDHQ:MessageTypeToCoalition( string.format( "铁血工造成功占领了 %s。 现在由'稻草人'接手防御，请协助巩固防御", ZoneCapture_02:GetZoneName()), MESSAGE.Type.Information )	
	end

	self:__Guard( 30 )

end
-- Zone2 end


ZoneCapture_01:Start( 5, 30 )
ZoneCapture_02:Start( 5, 30 )


TASK_BLUE = TASK_CAPTURE_DISPATCHER:New( BLUE_Mission, BLUE_PLANES_SET)
task_BLUE_01 = TASK_BLUE:AddCaptureZoneTask(
	"协助占领铁血前线防御基地",
	ZoneCapture_01,
	"长途奔袭至任务区域，消灭地面威胁，掩护格里芬运输机抵达作战空域并完成战略输送任务。"
	)
task_BLUE_02 = TASK_BLUE:AddCaptureZoneTask(
	"协助占领铁血后方主基地",
	ZoneCapture_02,
	"长途奔袭至任务区域，消灭地面威胁，掩护格里芬运输机抵达作战空域并完成战略输送任务。"
	)

TASK_RED = TASK_CAPTURE_DISPATCHER:New( RED_Mission, RED_PLANES_SET)
task_RED_01 = TASK_RED:AddCaptureZoneTask(
	"协助防御铁血前线防御基地",
	ZoneCapture_01,
	"在目标空域战略输送"
	)
task_RED_01 = TASK_RED:AddCaptureZoneTask(
	"协助防御铁血后方主基地",
	ZoneCapture_02,
	"在目标空域战略输送"
	)

MESSAGE:New("任务规划完成，请查看通讯菜单中获取详情", 10, "纵向应变子任务", true):ToAll()